import { HTTP } from '../util/http.js'
class LoginModel extends HTTP {
  userKey = 'username';
  loginByPost(username,password) {
    return this.request({
      method: 'post',
      url: 'jwt-auth/v1/token',
      data: {
        username,
        password
      }
    })
  }
  
  getDrafts(offset){
    return this.request({
      url: 'pipipi/v1/drafts',
      data: {
        offset: offset ? offset : 0
      }
    });
  }
  setUserName(username){
    wx.setStorageSync(this.userKey, username);
  }
  getUserName(){
    return wx.getStorageSync(this.userKey) || '';
  }
}
export { LoginModel }